import { badminton } from './DataTypes'

export function DecodeUserData (data: string): badminton.proto.IUserData {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeUserData (data:badminton.proto.IUserData): string {
  return JSON.stringify(data)
}

export function DecodeAdRewardReq (data: string): badminton.proto.IAdRewardReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeAdRewardResp (data: badminton.proto.IAdRewardResp): string {
  return JSON.stringify(data)
}

export function DecodeChestOperateReq (data: string):badminton.proto.IChestOperateReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeChestOperateResp (data: badminton.proto.IChestOperateResp): string {
  return JSON.stringify(data)
}

export function DecodeActorTryReq (data: string):badminton.proto.IActorTryReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeActorTryResp (data: badminton.proto.IActorTryResp): string {
  return JSON.stringify(data)
}

export function DecodeActorBattleReq (data: string):badminton.proto.IActorBattleReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeActorBattleResp (data: badminton.proto.IActorBattleResp): string {
  return JSON.stringify(data)
}

export function DecodeActorUpgradeReq (data: string):badminton.proto.IActorUpgradeReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeActorUpgradeResp (data: badminton.proto.IActorUpgradeResp): string {
  return JSON.stringify(data)
}

export function DecodeActorEquipReq (data: string):badminton.proto.IActorEquipReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeActorEquipResp (data: badminton.proto.IActorEquipResp): string {
  return JSON.stringify(data)
}

export function DecodeEquipmentUpgradeReq (data: string):badminton.proto.IEquipmentUpgradeReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeEquipmentUpgradeResp (data: badminton.proto.IEquipmentUpgradeResp): string {
  return JSON.stringify(data)
}

export function DecodeMatchLockReq (data: string):badminton.proto.IMatchLockReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeMatchLockResp (data: badminton.proto.IMatchLockResp): string {
  return JSON.stringify(data)
}

export function DecodeMatchCancelReq (data: string):badminton.proto.IMatchCancelReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeMatchCancelResp (data: badminton.proto.IMatchCancelResp): string {
  return JSON.stringify(data)
}

export function DecodeMatchResultReq (data: string):badminton.proto.IMatchResultReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeMatchResultResp (data: badminton.proto.IMatchResultResp): string {
  return JSON.stringify(data)
}

export function DecodeEnterGameReq (data: string):badminton.proto.IEnterGameReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeEnterGameResp (data: badminton.proto.IEnterGameResp): string {
  return JSON.stringify(data)
}

export function DecodeGameSettlementReq (data: string):badminton.proto.IGameSettlementReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeGameSettlementResp (data: badminton.proto.IGameSettlementResp): string {
  return JSON.stringify(data)
}

export function DecodeBeginnerRewardReceiveReq (data: string):badminton.proto.IBeginnerRewardReceiveReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeBeginnerRewardReceiveResp (data: badminton.proto.IBeginnerRewardReceiveResp): string {
  return JSON.stringify(data)
}

export function DecodeTourPointRewardReceiveReq (data: string):badminton.proto.ITourPointRewardReceiveReq {
  if (!data || data.length == 0) return {}
  return JSON.parse(data)
}

export function EncodeTourPointRewardReceiveResp (data: badminton.proto.ITourPointRewardReceiveResp): string {
  return JSON.stringify(data)
}